<?php

namespace IMT\DashboardBundle\Controller;

use IMT\lugins\ParticipantsBundle\Entity\ParticipantEvent;

use IMT\AccountBundle\Entity\AccountGmail;
use IMT\AccountBundle\Entity\AccountIMT;
use IMT\UserBundle\Entity\Contact;
use IMT\EventBundle\Entity\Event;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;


class DefaultController extends Controller
{
    
    public function indexAction()
    {
    	$emEvent = $this->container->get('imt_event.event_manager');
    	$securityContext = $this->get('security.context');
    	$user = $securityContext->getToken()->getUser();
    	    	
    	$em = $this->getDoctrine()->getEntityManager();
//     	$repo = $this->getDoctrine()->getRepository('IMTAccountBundle:Account');
//     	$account = $repo->findOneBy(array("id" => 1));
    	
//     	$repoContact = $this->getDoctrine()->getRepository('IMTUserBundle:Contact');
//     	$contact = $repoContact->findOneBy(array("id" => 1));
//     	$contact2 = $repoContact->findOneBy(array("id" => 2));

//     	$account = new AccountGmail();
//     	$account->setActive(true);
//     	$account->setColor('fc-event-azul');
//     	$account->setTitle('Compte IMT');
//     	$account->setUser($user);
//     	$em->persist($account);
//     	$em->flush();
    	
//     	$contact = new Contact();
//     	$contact->setCivility('Mr');
//     	$contact->setFirstname('Mark');
//     	$contact->setName('Hermann');
//     	$contact->setUser($user);
//     	$contact->addAccount($account);
//     	$em->persist($contact);
//     	$em->flush();
    	
//     	$contact2 = new Contact();
//     	$contact2->setCivility('Mr');
//     	$contact2->setFirstname('Franck');
//     	$contact2->setName('Arsène');
//     	$contact2->setUser($user);
//     	$contact2->addAccount($account);
//     	$em->persist($contact2);
//     	$em->flush();
    	
//     	$account->addContact($contact);
//     	$account->addContact($contact2);
//     	$em->persist($account);
//     	$em->flush();

    	
//     	$event = $emEvent->createEvent();
    	 
//     	$event->setImportance(1);
//     	$event->setTitle('test');
//     	$event->setOwner($user);
//     	$event->setContent('');
//     	$event->setAllDay(true);
//     	$event->setAccount($account);
    	
//     	$participantEvent = new \IMT\Plugins\ParticipantsBundle\Entity\ParticipantEvent();
//     	//$participantEvent->setAccount(NULL);
//     	$participantEvent->setParticipant($contact);
//     	$participantEvent->setParticipationState(0);
    	
//     	$event->addParticipantEvent($participantEvent);
//     	//var_dump($event);
    	 
//     	$emEvent->updateEvent($event);
    	
        return $this->render('IMTDashboardBundle:Default:index.html.twig');
    }
}
